<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="./css/style.css" rel="stylesheet" type="text/css" />
<link href="./css/dtree.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="./js/dtree-permit.js"></script>
<script type="text/javascript" language="javascript">
<!--
	function checkForm(){
		var roleName = document.getElementById("roleName");
		var roleDesc = document.getElementById("roleDesc");
		
		var functionIds = document.getElementsByName("cFunction");
		
		if(roleName.value == ""){
			alert("角色名称不能为空！");
			return false;
		}
		if(roleDesc.value == ""){
			alert("角色描述不能为空！");
			return false;
		}
		
		var sign = 0;
		for(var i = 0; i < functionIds.length; i++){
			if(functionIds[i].checked)sign = sign + 1;
		}
		
		if(sign <= 0){
			alert("请选择权限菜单树！");
			return false;
		}
		return true;
	}
	
	function back(){
		window.location.href = "./role.do";
		window.location.target = "main";
	}
	
	function save(){
		if(checkForm()){
			document.addRoleForm.action = "./role.do?action=addRole";
			document.addRoleForm.target = "main";
			document.addRoleForm.submit();
		}
	}
	
	function addSaleRecord(){
		window.location.href = "addSaleRecord.html";
		window.location.target = "main";
	}
	
	function updateSaleRecord(){
		window.location.href = "updateRecord.html";
		window.location.target = "main";
	}
-->
</script>
</head>
<body>
<form name="addRoleForm" action="" method="post">
	<a class="common_title">您现在的位置：基础设置 >> 新增角色</a>
	
	<div class="tools">
		<!-- <input class="btn1" type="button" value="指定用户" onclick="">&nbsp; -->
		<a class="save" href="javascript:save();" title="保存" hidefocus="true">保存</a>&nbsp;&nbsp;
		<a class="back" href="javascript:back();" title="返回" hidefocus="true">返回</a>&nbsp;&nbsp;
	</div>
	
<table class="table1">
	<tr>
		<td valign="top" width="">
			<table class="table_input" cellpadding="0" cellspacing="0" style="margin: 0 0 0 100px;">
				<tr>
					<td class="title3" width="15%">角色编号：</td>
					<td class="title3">${roleCode}<input id="roleCode" name="roleCode" type="hidden" value="${roleCode}"/></td>
				</tr>
				<tr>
					<td class="title3" width="15%">角色名称：</td>
					<td class="title3" width="">
						<input id="roleName" name="roleName" class="input1" type="text"/>
						<!-- &nbsp;
						<input class="btn1" type="button" value="复制角色" onclick="">
						 -->
					</td>
				</tr>
				<tr>
					<td class="title3" width="15%">角色描述：</td>
					<td class="title3" width="">
						<input id="roleDesc" name="roleDesc" class="input1" type="text"/>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td valign="top" style="border-top: solid 1px #94b8e9;"><font style="height: 30px;"></font>
			<table class="table_input" cellpadding="0" cellspacing="0" style="margin: 0 0 0 100px;">
				<tr>
					<td class="title3">
						<script type="text/javascript">
						<!--				
							d = new dTree('d');
							d.add('0','-1','<font color=#4269B4><b>权限菜单树</b></font>');
						//-->
						</script>
						
						<c:forEach var="function" items="${functions}">
						<script type="text/javascript">
						<!--				
							d.add(${function.id},${function.parentId},'cFunction','${function.id}','${function.functionName}','','','','','','','','');
						//-->
						</script>
						
							<c:forEach var="action1" items="${actions}">
							<c:if test="${action1.functionId == function.id}">
							<script type="text/javascript">
							<!--				
								d.add(${action1.id}+1000,${action1.functionId},'cAction','${action1.functionId}#${action1.id}','${action1.actionName}','','','','','','','','');
							//-->
							</script>
							</c:if>
							</c:forEach>
							
						</c:forEach>
						
						<script type="text/javascript">
						<!--				
							document.write(d);
						//-->
						</script>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>
</form>
</body>
</html>